<style type="text/css">
.img_a {
   margin-left: -6px; 
   margin-top: -6px; 
}
</style>

<form id="pagerForm" method="post" action="index.php?c=Goods&a=index">
    <input type="hidden" name="pageNum" value="{$search.pageNum}" />
    <input type="hidden" name="keywords" value="{$search.keywords}">
    <input type="hidden" name="star" value="{$search.star}">
    <input type="hidden" name="end" value="{$search.end}">
    <input type="hidden" name="shop_name" value="{$search.shop_name}">
    <input type="hidden" name="city" value="{$search.city}">
    <input type="hidden" name="numPerPage" value="{$pages.numPerPage}" />
    <input type="hidden" name="orderField" value="{$param.orderField}" />
    <input type="hidden" name="buygroup" value="{$search.buygroup}" />
    <input type="hidden" name="categroy" value="{$search.categroy}" />
    <input type="hidden" name="zifenlei" value="{$search.zifenlei}" />
    <input type="hidden" name="activity" value="{$search.activity}" />
    <input type="hidden" name="field" value="{$search.field}" />
    <!-- <input type="hidden" name="orderField" value="{$pages.currentPage}" /> -->
</form>

<link rel="stylesheet" type="text/css" href="css/default1.css" />
<!-- Edit Below -->
<script type="text/javascript" src="./js/jquery.wheelmenu.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href='css/elusive-webfont.css' rel='stylesheet' type='text/css'>
<div class="pageHeader">
    <form rel="pagerForm" onsubmit="return navTabSearch(this);" action="index.php?c=Goods&a=index" method="post">
        <div class="searchBar">

            <div class="subBar">
                <ul>
                    <li>
                    	<div class="buttonActive">

	                    <div class="buttonContent">
	                    	<button type="submit">刷新页面</button>
                            <li><a class="button" href="index.php?c=Goods&a=search" target="dialog" mask="true" title="查询框" width="800" height="600" ><span>高级检索</span></a></li>
	                    </div></div>
                    </li>
                </ul>
            </div>
        </div>
    </form>
</div>

<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <li>
	            <a class="add" href="index.php?c=Goods&a=add" target="dialog" width="800" height="600">
	            	<span>新增</span>
	            </a>
            </li>
            <li>
	            <a class="edit"  href="index.php?c=Goods&a=edit&uid={sid_user}"  target="navTab" width="800" height="600">
	            	<span>修改</span>
	            </a>
            </li>
            <li>
	            <a class="icon" onclick="jqchk(0)"  width="800" height="600">
	            	<span>审核不通过</span>
	            </a>
            </li>
            <li>
	            <a class="icon" onclick="jqchk(1)" width="800" height="600">
	            	<span>审核通过</span>
	            </a>
            </li>
            <li>
<!--                 <a onclick="del()"  width="800" height="600" id="1">
    <span>删除</span>
</a> -->
                <a class="delete" href="index.php?c=Goods&a=del" onclick="del()" callback="Delcb" target="ajaxTodo" title="确定要删除吗？" warn="请选择一个商品">
                    <span>删除</span>
                </a>

            </li>
        </ul>
    </div>

    <div id="w_list_print">
    <!-- <form id="tables" action="index.php?c=Present&a=presentCheck" method="post" accept-charset="utf-8"> -->
        <table class="list" width="100%" targetType="navTab" asc="asc" desc="desc" layoutH="116">
            <thead>
            <tr>
                <th align="center" width="10" ><input class="checkedAll" type="checkbox" value="{$goods.goodsid}"/></th>
                <th align="center" width="80" orderField="id" >id</th>
                <!-- <th align="center" width="200">特价区域</th> -->
                <th align="center" width="100" orderField="account_money">审核状态</th>
                <th align="center" width="100">店铺名称</th>
                <th align="center" width="200">商品名称</th>
                <th align="center" width="100">猜你喜欢</th>
                <th align="center" width="100">特价</th>
                <th align="center" width="100">扫货</th>
                <th align="center" width="100">限时折扣</th>
                <th align="center" width="100">为您挑货</th>
                <th align="center" width="100">拼团专区</th>
                <th align="center" width="100">9.9专区</th>
                <th align="center" width="100">商品图片</th>
                <th align="center" width="150">商品分类</th>
                <th align="center" width="100">出售价格</th>
                <th align="center" width="100">销量</th>
                <th align="center" width="100">上架时间</th>
                <!-- <th align="center" width="100">操作</th> -->
            </tr>
            </thead>
            <ul id="wheel7" data-angle="E" class="wheel">
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 1, '扫货')">
                        <img src="Public/images/saohuo-icon.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 2, '限时折扣')">
                        <img src="Public/images/xianshi-icon.png" class="img_a" >
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 3, '首选商品')">
                        <img src="Public/images/sc.png" class="img_a" style="width: 35px; height: 35px;">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 4, '排行榜')">
                        <img src="Public/images/paihang-icon.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 5, '为您挑货')">
                        <img src="Public/images/xiangyao-icon.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 6, '天天上新')">
                        <img src="Public/images/shangxin-icon.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 7, '拼团专区1')">
                        <img src="Public/images/ping1.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 8, '拼团专区2')">
                        <img src="Public/images/ping2.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 9, '拼团专区3')">
                        <img src="Public/images/ping3.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="specific({sid_user}, 10, '9.9专区')">
                        <img src="Public/images/9.png" class="img_a">
                    </a>
                </li>
            </ul>

            <ul id="wheel6" data-angle="W" class="wheel">
                <li class="item">
                    <a href="#home" onclick="group_buy({sid_user}, 0, 0, '已关闭')">
                        <img src="Public/images/guan.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="group_buy({sid_user}, 1, 1, '拼团专区1')">
                        <img src="Public/images/ping1.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="group_buy({sid_user}, 1, 2, '拼团专区2')">
                        <img src="Public/images/ping2.png" class="img_a">
                    </a>
                </li>
                <li class="item">
                    <a href="#home" onclick="group_buy({sid_user}, 1, 3, '拼团专区3')">
                        <img src="Public/images/ping3.png" class="img_a">
                    </a>
                </li>
            </ul>
            <tbody id="Fares">
            	<foreach name="goods" item="goods">
		            <tr target="sid_user" rel="{$goods.goodsid}">
		            	<td><input type="checkbox" name="review[]" value="{$goods.goodsid}"></td>
                        <div class="main">
                            <td><a href="#wheel7" class="wheel-button e">{$goods.goodsid}</a></td>
                        </div>
                        <!-- main -->
						<!-- </td> -->
						<if condition="$goods['check'] eq 0"><td style="color: #f2b818;">待审核</td>
						<elseif condition="$goods['check'] eq 2"/><td style="color: #ea3609;">未审核通过</td>
						<elseif condition="$goods['check'] eq 1"/><td style="color: #47c91c;">已审核通过</td>
						</if>
                        <td>{$goods.shop_name}</td>
						<td>{$goods.title}</td>
						<!-- <td>{$goods.city_name}</td> -->

						<if condition="$goods['xihuan'] eq 0">
                        <td id="xihuan{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 1, 'xihuan')">已关闭</td>
						<else />
                        <td id="xihuan{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'xihuan')")>已开启</td>
						</if>

						<if condition="$goods['tejia'] eq 0">
                        <td id="tejia{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 1, 'tejia')")>已关闭</td>
						<else />
                        <td id="tejia{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'tejia')")>已开启</td>
						</if>

						<if condition="$goods['act_saohuo'] eq 0">
                        <td id="act_saohuo{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 2, 'act_saohuo')")>已关闭</td>
						<elseif condition="$goods['act_saohuo'] eq 2"/>
                        <td id="act_saohuo{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'act_saohuo')")>已开启</td>
						</if>

						<if condition="$goods['act_xianshizhekou'] eq 0">
                        <td id="act_xianshizhekou{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 2, 'act_xianshizhekou')")>已关闭</td>
						<elseif condition="$goods['act_xianshizhekou'] eq 2"/>
                        <td id="act_xianshizhekou{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'act_xianshizhekou')")>已开启</td>
						</if>

						<if condition="$goods['act_nixiangyaode'] eq 0">
                        <td id="act_nixiangyaode{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 2, 'act_nixiangyaode')")>已关闭</td>
						<elseif condition="$goods['act_nixiangyaode'] eq 2"/>
                        <td id="act_nixiangyaode{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'act_nixiangyaode')")>已开启</td>
						</if>

                        <div class="main">
                            <if condition="$goods['buygroup_id'] eq 0">
                                <td>
                                    <a href="#wheel6" class="wheel-button e" id="group_buy{$goods.goodsid}" style="color: #ea3609;">已关闭</a>
                                </td>
                            <elseif condition="$goods['buygroup_id'] eq 1"/>
                                <td>
                                    <a href="#wheel6" class="wheel-button e" id="group_buy{$goods.goodsid}" style="color: #47c91c;">拼团专区1</a>
                                </td>
                            <elseif condition="$goods['buygroup_id'] eq 2"/>
                                <td>
                                    <a href="#wheel6" class="wheel-button e" id="group_buy{$goods.goodsid}" style="color: #47c91c;">拼团专区2</a>
                                </td>
                            <elseif condition="$goods['buygroup_id'] eq 3"/>
                                <td>
                                    <a href="#wheel6" class="wheel-button e" id="group_buy{$goods.goodsid}" style="color: #47c91c;">拼团专区3</a>
                                </td>
                            </if>
                        </div>

                        <if condition="$goods['isnice'] eq 0">
                        <td id="isnice{$goods.goodsid}" style="color: #ea3609; cursor:pointer;" onclick="activity({$goods.goodsid}, 1, 'isnice')")>已关闭</td>
                        <elseif condition="$goods['isnice'] eq 1"/>
                        <td id="isnice{$goods.goodsid}" style="color: #47c91c; cursor:pointer;" onclick="activity({$goods.goodsid}, 0, 'isnice')")>已开启</td>
                        </if>

						<!-- <td>{$goods.act_nixiangyaode}</td> -->
						<td><img src="__LOCALHOST__/{$goods.images}" style="width: 70px; height: 70px;" /></td>
						<td>{$goods.city_name}-{$goods.cate_name}</td>
						<td>{$goods.price}</td>
						<td>{$goods.xiaoliang}</td>
                        <td>{$goods.addtime}</td>
						<!-- <td>通过审核</td> -->
		            </tr>
		        </foreach>
            </tbody>
        </table>
        <input type="hidden" name='checking' />
    <!-- </form> -->
    </div>

    <div class="panelBar" >
        <div class="pages">
            <span>显示</span>
            <select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="{$pages.numPerPage}">{$pages.numPerPage}</option>
                <option value="50">50</option>
                <option value="100">100</option>
                <option value="200">200</option>
            </select>
            <span>条，共{$pages.total}条</span>
        </div>

        <div class="pagination" targetType="navTab" totalCount="{$pages.total}" numPerPage="{$pages.numPerPage}" pageNumShown="10" currentPage="{$pages.currentPage}"></div>

    </div>

</div>
<script>
  $('td').attr({align:"center"});
  $('.checkedAll').on({
    change:function(){
      $(this).prop('checked')?$(":checkbox[name='review[]']").prop('checked',true):$(":checkbox[name='review[]']").prop('checked',false);
    },
  });
    //删除回调
  function submited(url,th){
    if( $(":checkbox:checked").not($('.checkedAll')).length>0 ){
      if(url=='0'){
        var w = confirm($(th).attr('warn'))?'1':'';
        $(":input[name='checking']").val('0');
      }else if(url=='1'){
        var w = confirm($(th).attr('warn'))?'1':'';
        $(":input[name='checking']").val('1');
      }
      if(w){
        $('#tables').submit();
      }
    }else{
      return false;
    }
  }
    //删除回调
    function Delcb(){
        $deltr = $('#Fares').find('tr.selected');
        $deltr.remove();
    }

    function jqchk(type){ //jquery获取复选框值 
    	var chk_value = [];
    	$('input[name="review[]"]:checked').each(function(){ 
    	chk_value.push($(this).val()); 
    	});

        $.ajax({
          type:"POST",
          url: "index.php?c=Goods&a=check",
          data: {"goodsid":chk_value, "type":type},
          dataType:'json',
          success:function(data){
          	console.log(data);
            if(data == 0) {
            	alert("审核不通过");
            } else {
            	alert("审核通过");
            }
          }
        });
	// alert(chk_value.length==0 ?'你还没有选择任何内容！':chk_value); 
    }

    function edit(){ //jquery获取复选框值 
        var chk_value = [];
        $('input[name="review[]"]:checked').each(function(){ 
            chk_value.push($(this).val()); 
        });
        $(".edit").attr("href","index.php?c=Goods&a=edit&goodsid="  + chk_value); 
    }

    function del() {
        
        var chk_value = [];
        $('input[name="review[]"]:checked').each(function(){ 
            chk_value.push($(this).val()); 
        });

        $.ajax({
          type:"POST",
          url: "index.php?c=Goods&a=del",
          data: {"goodsid":chk_value},
          dataType:'json',
          success:function(data){

          }
        });

    }

    //删除回调
    function Delcb(){
        $deltr = $('#Fares').find('tr.selected');
        $deltr.remove();
    }

    /**
     * [特价区域操作]
     * @Author   Hybrid
     * @DateTime 2017-08-08
     * @param    {[type]}   id     [description]
     * @param    {[type]}   type   [description]
     * @param    {[type]}   action [description]
     * @return   {[type]}          [description]
     */
    function activity(id, type, action) {
        $.ajax({
          type:"POST",
          url: "index.php?c=Goods&a=activity",
          data: {"id":id, "type":type, "action":action},
          dataType:'json',
          success:function(data){
                if(data.msg == 'on') {
                    $('#' + action + id).attr('onclick','activity('+ id +',0,"'+ action +'")');
                    $('#' + action + id).css("color","#47c91c"); 
                    $('#' + action + id).text('已开启');
                } else if(data.msg == 'off') {
                    $('#' + action + id).attr('onclick','activity('+ id +',2,"'+ action +'")');
                    $('#' + action + id).css("color","#ea3609"); 
                    $('#' + action + id).text('已关闭');
                }
          }
        });
    }
    $(".wheel-button").wheelmenu();

    /**
     * [选为特定区域]
     * @Author   Hybrid
     * @DateTime 2017-08-09
     * @param    {[type]}   array [description]
     * @param    {[type]}   type  [description]
     * @param    {[type]}   str   [description]
     * @return   {[type]}         [description]
     */
    function specific(array, type, str) {
        var goodsid = array.sid_user.value;
        $.ajax({
          type:"POST",
          url: "index.php?c=Goods&a=specific",
          data: {"goodsid":goodsid, "type":type, "str":str},
          dataType:'json',
          success:function(data){
                alert(data.msg);
          }
        });
    }

    /**
     * [选取拼团专区]
     * @Author   Axing
     * @DateTime 2017-08-21
     * @param    {[type]}   array       [description]
     * @param    {[type]}   istuangou   [description]
     * @param    {[type]}   buygroup_id [description]
     * @param    {[type]}   str         [description]
     * @return   {[type]}               [description]
     */
    function group_buy(array, istuangou, buygroup_id, str) {
        var goodsid = array.sid_user.value;
        $.ajax({
          type:"POST",
          url: "index.php?c=Goods&a=group_buy",
          data: {"goodsid":goodsid, "istuangou":istuangou, "buygroup_id":buygroup_id, "str":str},
          dataType:'json',
          success:function(data){
                if(data.msg = true) {
                    $('#group_buy'+goodsid).text(str);
                    if(istuangou == 0 && buygroup_id == 0) {
                        $('#group_buy'+goodsid).css("color","#ea3609"); 
                    } else {
                        $('#group_buy'+goodsid).css("color","#387a3f"); 
                    }
                    
                }
          }
        });
    }
</script>